﻿using Snake.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BarrierGenarator.Data
{
    class General
    {
        public static List<LocationD> Walls = new List<LocationD>();
        public static List<LocationD> Traps = new List<LocationD>();
        public static LocationD SnakeHead = new LocationD();
        public static int SnakeSize;
        public static GateMangerD Gates = new GateMangerD()
        {
            Gates = new List<GateD>()
        };
        public static SizeD Size { get; set; }
        public static bool CheckWallExist(LocationD location)
        {
            var result = false;
            foreach(var p in Walls)
            {
                if (p.X == location.X && p.Y == location.Y)
                {
                    result = true;
                    break;
                }
            }
            return result;
        }
        
        public static LocationD GetWall(LocationD location)
        {
            foreach(var p in Walls)
            {
                if (p.X == location.X && p.Y == location.Y)
                {
                    return p;
                }
            }
            return new LocationD();
        }

        public static bool CheckTrapExist(LocationD location)
        {
            var result = false;
            foreach (var p in Traps)
            {
                if (p.X == location.X && p.Y == location.Y)
                {
                    result = true;
                    break;
                }
            }
            return result;
        }
        public static LocationD GetTrap(LocationD location)
        {
            foreach(var p in Traps)
            {
                if(p.X==location.X&&p.Y==location.Y)
                {
                    return p;
                }
            }
            return new LocationD();
        }

        public static bool CheckGateExist(LocationD location)
        {
            var result = false;
            foreach (var p in Gates.Gates)
            {
                if (p.Location.X == location.X && p.Location.Y == location.Y)
                {
                    result = true;
                    break;
                }
            }
            return result;
        }
        public static GateD GetGate(LocationD location)
        {
            foreach (var p in Gates.Gates)
            {
                if (p.Location.X == location.X && p.Location.Y == location.Y)
                {
                    return p;
                }
            }
            return new GateD();
        }
    }
}
